package cc.yugu.yhdw.common.utils;

import ch.hsr.geohash.GeoHash;
import ch.hsr.geohash.WGS84Point;
import ch.hsr.geohash.util.VincentyGeodesy;

public class GeoHashUtils {
    private static final int NUMBER_OF_CHARACTERS = 8;

    public static String getGeoHashString(double lng, double lat) {
        return GeoHash.geoHashStringWithCharacterPrecision(lat, lng, NUMBER_OF_CHARACTERS);
    }

    public static double getDistanceInMeters(double lng1, double lat1, double lng2, double lat2) {
        return VincentyGeodesy.distanceInMeters(new WGS84Point(lat1, lng1), new WGS84Point(lat2, lng2));
    }
}
